import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ComponentVO, ComponentForm, ComponentQuery } from '@/api/logic/component/types';

/**
 * 查询组件管理列表
 * @param query
 * @returns {*}
 */

export const listComponent = (query?: ComponentQuery): AxiosPromise<ComponentVO[]> => {
  return request({
    url: '/logic/component/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询组件管理详细
 * @param componentId
 */
export const getComponent = (componentId: string | number): AxiosPromise<ComponentVO> => {
  return request({
    url: '/logic/component/' + componentId,
    method: 'get'
  });
};

/**
 * 新增组件管理
 * @param data
 */
export const addComponent = (data: ComponentForm) => {
  return request({
    url: '/logic/component',
    method: 'post',
    data: data
  });
};

/**
 * 修改组件管理
 * @param data
 */
export const updateComponent = (data: ComponentForm) => {
  return request({
    url: '/logic/component',
    method: 'put',
    data: data
  });
};

/**
 * 删除组件管理
 * @param componentId
 */
export const delComponent = (componentId: string | number | Array<string | number>) => {
  return request({
    url: '/logic/component/' + componentId,
    method: 'delete'
  });
};
